﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace System.Runtime.Caching
{
    public static class DefaultCache
    {
        //public static IList<T> GetListFromCache<T>(this IQueryable<T> query)
        //{
        //    string cacheKey = typeof(T).ToString() + query.GetHashCode();
        //    var data = MemoryCache.Default[cacheKey] as IList<T>;
        //    if (data == null)
        //    { 
        //        data = query.ToList();
        //        var command = query.ToSqlCommand();
        //        var policy = new CacheItemPolicy();
        //        policy.SlidingExpiration = TimeSpan.FromMinutes(5);
        //        (query as System.Data.Entity.Infrastructure.DbQuery).
        //        policy.ChangeMonitors.Add(new SqlEFChangeMonitor(command, _dbContext.ConnectionString));
        //        MemoryCache.Default.AddOrGetExisting(cacheKey, data, policy);
        //    }
        //    return data;
        //}
    }
}
